﻿#region Namespaces

using System.Collections.Generic;

using Vibstudio.X4NET.Xml.Linq;

#endregion

namespace Vibstudio.X4NET.Xml.XPath
{
    internal class AttributeXPathName : IObjectXPathName
    {
        public string GetXPathName(XObject node, IDictionary<string, string> namespacePrefixes)
        {
            var attribute = (XAttribute)node;
            string preffix;
            namespacePrefixes.TryGetValue(attribute.Name.NamespaceName, out preffix);

            return string.Format("@{0}", XPathExtensions.BuildXPathName(preffix, attribute.Name.LocalName));
        }
    }
}